package open.witype.filetiper.fragment.menu.adapter;

import open.witype.filetiper.R;
import open.witype.filetiper.activity.home.HomeActivity;
import open.witype.filetiper.custom.DragRecyclerView;
import open.witype.filetiper.fragment.menu.db.FavoDBAdapter;
import open.witype.filetiper.fragment.menu.adapter.MenuRecyclerAdapter;
import open.witype.filetiper.activity.home.interf.OnItemClickListener;

/**
 * Created by Typer on 2015/6/1 0001.
 */
public class SlidingmenuAdaper {

    public static String ROOT = "";

    private HomeActivity activity;

    private DragRecyclerView recyclerView;

    private MenuRecyclerAdapter adapter;

    private OnItemClickListener itemClickListener;

    public SlidingmenuAdaper(HomeActivity activity,OnItemClickListener itemClickListener){
        this.activity = activity;
        this.itemClickListener = itemClickListener;
        initRecycler();
    }

    public void initRecycler(){
        recyclerView = (DragRecyclerView)activity.findViewById(R.id.menu_recycler);
        FavoDBAdapter dbAdapter = FavoDBAdapter.getInstance(activity);
        dbAdapter.open();
        adapter = new MenuRecyclerAdapter(dbAdapter.getFavoList());
        dbAdapter.close();
        adapter.setItemClickListener(itemClickListener);
        recyclerView.setAdapter(adapter);
    }

    public void setItemClickListener(OnItemClickListener itemClickListener) {
        this.itemClickListener = itemClickListener;
    }
}
